<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>作用域插槽的案例</title>
    <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
</head>
<body>
    <div id="app">
        <cpn2>
            <!-- 目的：获取子组件中的planguages -->
            <template v-slot="data">
                <span v-for="item in data">{{item}}</span>
            </template>
        </cpn2>
      <cpn2></cpn2>
      <cpn2></cpn2>
    </div>
    
    <template id="cpn2">
        <div>
            <!-- 这里是将子组件的数据传给Vue实例 -->
           <slot :data="pLanguages">
            <ul>
                <li v-for="item in pLanguages">{{ item }}</li>
            </ul>
           </slot>
        </div>
    </template>
    <script>
       
        const app = new Vue({
            el: "#app",
            data: {
                message: "你好啊",
               
            },
            components:{//局部组件注册语法糖
                cpn2:{
                    template: "#cpn2",
                    data() {
                    return {
                        pLanguages: ['javascript', 'c++', 'java', 'python']
                    }
                }
                }
               
            }
        })
    </script>
</body>
</html>